<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<jsp:include page="../admin.jsp"></jsp:include>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>广告管理</title>
		<jsp:include page="../../../inc/js.jsp"></jsp:include>
		<jsp:include page="../../../inc/css.jsp"></jsp:include>
		<script type="text/javascript">
function movePage(pageNo) {
	window.location = '?pageNo=' + pageNo + param();
}
function param() {
	return '&name=' + $("#name").val();
}
$(function() {
	$("#search").button().click(function() {
		movePage(1);
	});
	$("#add").button().click(function() {
		location.href = "advEdit.do";
	});
});
function del(id) {
	if (confirm('确认删除？')) {
		$.ajax( {
			type : "get",
			url : "deleteAdv.do?" + Math.random(),
			data : {
				id : id
			},
			dataType : 'json',
			error : function() {
				alert("加载错误");
			},
			success : function(data) {
				if (data.success) {
					clearApplication();
					alert('操作成功！');
					location = '?';
				} else
					alert('操作失败！\r\n' + data.err);
			}
		});
	}
}
</script>
	</head>
	<body><jsp:include page="functionPath.jsp">
	<jsp:param value="${url}" name="url"/>
</jsp:include>
		<table class="list" cellpadding="0" cellspacing="1">
			<thead>
				<tr>
					<td class="search" colspan="7">
						名称：
						<input type="text" name="name" id="name" value="${param.name}" />
						<button id="search">
							查询
						</button>
						<button id="add">
							添加
						</button>
					</td>
				</tr>
				<tr>
					<td>
						名称
					</td>
					<td >
						图片
					</td>
					<td>
						URL
					</td>
					<td >
						位置
					</td>
					<td >
						排序编号
					</td>
					<td >
						启用
					</td>
					<td >
						操作
					</td>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="e" items="${o.dataList}" varStatus="s">
					<tr>
						<td>
							<a href="advEdit.do?id=${e.id}">${e.name}</a>
						</td>
						<td>
							<c:if test="${!empty e.img}">
								<a href="${e.img }" target="_blank"><img src='${e.img }'
										style="height: 30px;" /> </a>
							</c:if>
						</td>
						<td>
							${e.url }
						</td>
						<td align="center">
							${e.type }
						</td>
						<td align="center">
							${e.orderid }
						</td>
						<td align="center">
							${e.enabled }
						</td>
						<td align="center">
							<a href="advEdit.do?id=${e.id}"><img
									src="lib/images/write.png" /> </a>
							<a href="javascript:del(${e.id})"><img
									src="lib/images/close.gif" /> </a>
						</td>
					</tr>
				</c:forEach>
			</tbody>
			<tfoot>
				<tr>
					<td colspan="7">
						${o.pageNav }
					</td>
				</tr>
			</tfoot>
		</table>
	</body>
</html>